<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>菜单栏</title>
    <style>
        button {
            padding: 10px 15px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }

        ul {
            display: none;
        }

        ul li {
            float: left;
            list-style: none;
            padding: 12px 20px;
        }
    </style>
</head>

<body>
    <button class="showMenuBtn">显示菜单栏</button>
    <ul class="menu"></ul>

</body>
<script>
    let menuItems = ["首页", "产品", "服务", "关于我们", "联系我们"];
    document.querySelector('.showMenuBtn').addEventListener('click', function () {
        const menu = document.querySelector('.menu')
        menu.innerHTML = menuItems.map(item => `<li>${item}</li>`).join('');
        menu.style.display = 'block';
    });
</script>

</html>